/**
 * 
 */
package name.yzhu.index;

import java.util.Map;

import org.apache.lucene.document.Field;

import name.yzhu.common.conf.YamlConfig;
import name.yzhu.common.yaml.YamlItem;

/**
 * indexed fields configuration
 * @author yhzhu
 *
 */
public class IndexFieldYamlCfg extends YamlConfig implements IndexerConfInterface{
	/**
	 * 
	 */
	private static final long serialVersionUID = 6346805857088478456L;
	
	private static final String FIELD_STORE = "field-store";

	private static final String FIELD_INDEX = "field-index";

	@Override
	public IndexFieldPropeties getIndexFieldProperties(String name) {
		Map<String, Object> field = getMap(name);
		if (field == null)
		    return null;
		
		YamlItem item = new YamlItem(field);
		IndexFieldPropeties pro = new IndexFieldPropeties();
		String fieldStore = item.getString(FIELD_STORE);
		if (fieldStore != null)
			pro.setFiledStore(Field.Store.valueOf(fieldStore));
		String fieldIndex = item.getString(FIELD_INDEX);
		if (fieldIndex != null)
			pro.setFiledIndex(Field.Index.valueOf(fieldIndex));
		
		return pro;
	}

}
